import {defineStore} from "pinia";

/**
 * 仓库数据结构
 */
interface Wh {
    logogram: string;
    org_id: string;
    wh_code: string;
    wh_id: string;
    wh_name: string;
}

export default defineStore("wh", {
    state() {
        const whList: Wh[] = [];

        return {
            loading: false,
            whList
        }
    },
    getters: {},
    actions: {
        reload() {
            this.loading = true
            system.getWh().then(axiosResponse => {
                const resp = axiosResponse.data
                if (resp.success) {
                    this.whList = resp.data;
                } else {
                    system.showErrorDialog(resp.msg)
                }

            }).finally(() => {
                this.loading = false;
            });
        }
    }
})
